//
//  ZZCSearchController.m
//  ZZC-Finance
//
//  Created by a on 2017/6/14.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ZZCSearchController.h"
#import "AFHTTPRequestOperationManager.h"
//首页我的搜索
@interface ZZCSearchController ()<UIWebViewDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *searchWebView;
@property (strong, nonatomic) NSURL *uurl;
@property (copy,   nonatomic) NSString *imgUrl;

@end

@implementation ZZCSearchController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.searchWebView.delegate = self;
    
    NSURL *h5_CLASSIFY = [NSURL URLWithString:ZZCURL_API_H5_SEARCH];
    NSURLRequest *request = [NSURLRequest requestWithURL:h5_CLASSIFY];
    
    //让内容自动适应屏幕大小
    self.searchWebView.scalesPageToFit = YES;
    [self.searchWebView loadRequest:request];
    [self.view addSubview:_searchWebView];

}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSLog(@"%@",request);
    if ([request.URL.absoluteString containsString:@"http://www.stlh.com/action===back"]) {
        NSLog(@"已拦截");
        [self.navigationController popToRootViewControllerAnimated:YES];
        
        return NO;
        
    }
    return YES;
}



//- (void)loadDate {
//    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//    
//    NSString *token = ZZCNSUserDefaults(@"token");
//    // 原本需要拼接get访问URL ? & =
//    NSDictionary *dict = @{@"token":token};
//    
//    // 网络访问是异步的,回调是主线程的,因此程序员不用管在主线程更新UI的事情
//    [manager GET:ZZCURL_API_H5_CLASSIFY parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSLog(@"%@", responseObject);
//        // 提问:NSURLConnection异步方法回调,是在子线程
//        // 得到回调之后,通常更新UI,是在主线程
////        NSLog(@"%@", [NSThread currentThread]);
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        NSLog(@"%@asdfsadfsadfsadfsadfsadfsadfasdfsadfffsadaddddddddddddddddd", error);
//    }];
//
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
